<template>

  <el-dialog title="邮件发送记录" :visible.sync="dialogVisible" width="30%" :close-on-click-modal="false">
  	<el-form :gutter="24" ref="search-box" label-position="left" label-width="150px" v-if="form != null && form.length > 0">
  		<el-form-item :label="item.emailSendTypeInfoName" size="mini" v-for="item in form">
        <el-input placeholder="" :value="item.strStatus" disabled></el-input>
      </el-form-item>
  	</el-form>
  	<p v-if="form != null && form.length == 0">暂无邮件发送记录</p>
  	<div slot="footer" class="dialog-footer">
  		<el-button @click="close" size="small">关闭</el-button>
  	</div>
  </el-dialog>

</template>

<script>

import ApiMain from '@/api/email.log';

export default {
  mixins: [
  ],
  props: [
  ],
  data () {
    return {

      dialogVisible: false,
      data: null,
      form: null,
      id: null,

    }
  },
  methods: {

    show (id = null) {

      this.id = id;

      this.fetchData();

      this.dialogVisible = true;
    },

    close () {
      this.dialogVisible = false;
      this.$emit('dialog-close');
    },

    fetchData () {
    	ApiMain.list({ page: 1, limit: 20, search: { tradeId: this.id } })
      .then(re => {
        this.data = re; 
      })
      .catch(() => {
        this.data = null;
      })
      .finally(() => {
        this.renderData();
      });
    },

    renderData () {
      this.form = this.data.list
    },

  }
}
</script>